<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>新浪下拉菜单</title>
		<style type="text/css">
			* {
				margin: 0;
				padding: 0;
			}
			li {
				list-style-type: none;
			}
			a{
				text-decoration: none;
				font-size: 14px;
			}
			.nav {
				margin: 100px;
			}
			.nav>li {
				position: relative;
				float: left;
				width: 80px;
				height: 41px;
				text-align: center;
			}
			.nav li a {
				display: block;
				width: 100%;
				height: 100%;
				line-height: 41px;
				color: #333;
			}
			.nav>li>a:hover {
				background-color: #eee;
			}
			.nav ul {
				display: none;
				position: absolute;
				top: 41px;
				left: 0;
				width: 100%;
				border-left: 1px solid #fecc5b;
				border-right: 1px solid #fecc5b;
			}
			.nav ul li {
				border-bottom: 1px solid #FECC5B;
			}
			.nav ul li a:hover {
				background-color: #fff5da;
			}
		</style>
	</head>
	<body>
		<ul class="nav">
			<li>
				<a href="">微博</a>
				<ul>
					<li><a href="">私信</a></li>
					<li><a href="">评论</a></li>
					<li><a href="">@我</a></li>
				</ul>
			</li>
			<li>
				<a href="">微博</a>
				<ul>
					<li><a href="">私信</a></li>
					<li><a href="">评论</a></li>
					<li><a href="">@我</a></li>
				</ul>
			</li>
			<li>
				<a href="">微博</a>
				<ul>
					<li><a href="">私信</a></li>
					<li><a href="">评论</a></li>
					<li><a href="">@我</a></li>
				</ul>
			</li>
		</ul>
	</body>
	<script type="text/javascript">
		//获取元素
		let nav = document.querySelector(".nav");
		let lis = nav.children;
		for(let i=0;i<lis.length;i++){
			lis[i].onmouseover = function() {
				//获取ul，并修改样式
				this.children[1].style.display  = "block";
			}
			lis[i].onmouseout = function() {
				this.children[1].style.display = "none"
			}
		}
	</script>
</html>
